package com.wkbb.common.base;

import com.github.pagehelper.PageInfo;

import java.util.List;
import java.util.Map;

public interface BaseService<T> {

	/**
	 * 查询单条数据
	 *
	 * @param id
	 * @return
	 * @throws Exception
	 */
	T getByPrimaryKey(final Long id) throws Exception;

	/**
	 * 查询单条数据
	 * 传入Map<String,String>类型查询条件
	 *
	 * @param params
	 * @return
	 * @throws Exception
	 */
	T getByMapParams(Map<String, Object> params) throws Exception;

	/**
	 * 传入Map<String,String>类型查询条件
	 *
	 * @param params
	 * @return
	 * @throws Exception
	 */
	List<T> getListByMapParams(Map<String, Object> params) throws Exception;

	/**
	 * 按条件分页查询
	 * @param params 条件
	 * @param pageNo 页码
	 * @param pageSize 每页条数
	 * @return
	 * @throws Exception
	 */
	PageInfo<T> getListByPage(Map<String, Object> params, final Integer pageNo, final Integer pageSize) throws Exception;

	/**
	 * 新增单个数据
	 * 
	 * @param entity
	 * @throws Exception
	 */
	void insert(final T entity) throws Exception;

	/**
	 * 批量新增数据
	 *
	 * @param list
	 * @throws Exception
	 */
	void insertBatch(List<T> list) throws Exception;

	/**
	 * 修改单个数据
	 *
	 * @param id
	 * @throws Exception
	 */
	void updateByPrimaryKey(final Long id) throws Exception;

	/**
	 * 修改单个数据
	 * 
	 * @param entity
	 * @throws Exception
	 */
	void update(final T entity) throws Exception;

	/**
	 * 批量修改数据
	 *
	 * @param list
	 * @throws Exception
	 */
	void updateBatch(List<T> list) throws Exception;
	
	/**
	 * 删除单个数据
	 * 
	 * @param id
	 * @throws Exception
	 */
	void deleteByPrimaryKey(final Long id) throws Exception;

	/**
	 * 删除单个数据
	 *
	 * @param entity
	 * @throws Exception
	 */
	void delete(final T entity) throws Exception;

	/**
	 * 批量删除数据
	 *
	 * @param list
	 * @throws Exception
	 */
	void deleteBatch(List<T> list) throws Exception;
}
